<template>
	    <view class='main'>			
			<view class="mine__bg" style="background-image: url(https://image.workair.top/uplaod/20250618/e9b2bb19f83d071d949c3c9bd21c22136e9f5d91.png);;padding-top: 140rpx;">
				<navbar  :btnColors='btnColor' title="申请提现" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
				
				<view class="margin-top">					  
				   <text style="font-size: 56rpx;color: #FFFFFF;">{{cash_info.balance}}</text>
					<text style="font-size: 24rpx;color: #FFFFFF;" class="mt-10">可提现收入</text>
				</view>						
			</view>		
			
			<view class="wallet_info">				
				<view class="flex justify-between  tag_text border-b  align-center text-center pt-30 pb-30 ml-30 mr-30">
					<view class="flex text-lg">
						<text>提现至 </text>
					</view>
					<view class="flex">
						<view class="flex cash_tye mr-20 "  :class="[currentTab == 0 ? 'active' : '']" :data-current="0" @click="changeNav">
							<text>银行卡</text>
						</view>
						<view class="flex cash_tye" :class="[currentTab == 1 ? 'active' : '']" :data-current="1" @click="changeNav">
							<text>微信零钱</text>
						</view>
					</view>				 
				</view>	
				
                <view class="flex justify-between  tag_text border-b  align-center text-center pt-30 pb-30 ml-30 mr-30"  v-if="currentTab==0">
					<view class="flex text-lg">
						<text>银行卡 </text>
					</view>
					<view class="flex align-center text-center" @click="bank_list">
						 <text class="mr-20">{{cash_info.bank_member.bank_names}}</text>
						 <u-icon name="arrow-right" color="rgba(3, 31, 55, 0.6);" size="15"></u-icon>
					</view>				 
			    </view>	
				
				<view class="flex flex-direction border-b pt-30 pb-30 ml-30 mr-30">
					 <view class="flex" style="font-weight: 600;font-size: 32rpx;color: #222222;">
					 	<text>提现金额 </text>
					 </view>
					 <view class="flex mt-25 justify-between align-center text-center">
						 <u--input
						     placeholder="请输入内容"
						 	placeholder-style="text-align: left;"
						     border="none"
						     clearable
						 	v-model="money"
						   ></u--input>
					 	<text style="font-size: 28rpx;color: #36B3E9;" class="mt-5" @click="all_money">全部提现</text>
					 </view>
				</view>				
				<button @click="formSubmit" >提交</button>
			</view>	
			
			<view class="flex flex-column flex-direction" style="margin-top: 60rpx;">
				<view class="remark">
					提现说明
				</view>
				<view class="cash">
					{{cash_info.member_limit_cash}}
				</view>
			</view>					
		</view>
</template>

<script>
	export default {
		data() {
			return {
				currentTab:0,
				cash_info:'',
				money:'',
				bankId:""
			};
		},		
		onLoad(options){
			if(options.bankId){
				this.bankId=options.bankId
			}
		    this.get_cash_limit()		
		},		  
		methods:{
			//银行卡
			bank_list(){
				this.$routers.router('/pages/pagesuser/bankList/index','navigateTo') 
			},
			//切换
			changeNav(e){
				console.log('e',e)
				this.currentTab = e.currentTarget.dataset.current;							
			},	
			
			 //全部提现
			all_money(){
				this.money=this.cash_info.balance
			},
			
			
			//金额限制
			get_cash_limit(){
			   let obj_data={
			    token:uni.getStorageSync('userInfo').token,	
				bankId:this.bankId,
				type:1,
			   }			   
			   this.$http.cash_limit(obj_data).then(res=>{
			      if(res.resCode=="9999"){
			       this.cash_info=res.data
				   if(res.data.bank_member){
					   this.bankId=res.data.bank_member.id
				   }
			      }     
			    })
			},
						
		    //提交信息
			formSubmit(){					
				let _that = this;
				
				let obj_data={}
				obj_data.token=uni.getStorageSync('userInfo').token;
				obj_data.money=this.money;
				obj_data.type=this.currentTab;
				obj_data.cash_type='member';
				obj_data.bankId=this.bankId;
				
				console.log('obj_data',obj_data)
				
				if(obj_data.type==0){
					if(!obj_data.bankId){
						uni.showModal({
							title: '提示',
							content: '请选择银行卡~!',
						})
						return false
					}
				}
					
				
				
				if (!obj_data.money) {
				  uni.showModal({
					title: '提示',
					content: '请输入提现金额!',
				  })
				  return false
				}
				
				if(obj_data.money*1< this.cash_info.min_money){
				  uni.showModal({
					title: '提示',
					content: '提现金额大于'+this.cash_info.min_money+'!',
				  })
				  return false
				}
				
				if(obj_data.money*1> this.cash_info.max_money){
				  uni.showModal({
					title: '提示',
					content: '提现金额小于'+this.cash_info.max_money+'!',
				  })
				  return false
				}
				
				
				
				
				this.loading=true
				
				
				this.$http.Pdocash(obj_data).then(res=>{
				  if(res.resCode=='9999'){
					uni.showToast({
						title: '操作成功，等待管理员审核!',
						icon: 'none'
					})
					setTimeout(function () {
					  //要延时执行的代码
						uni.navigateTo({
						  url: '/pages/pagesuser/docash/index?currentTab=1',
						  success: function (e) {
							let page = getCurrentPages().pop();
							page.onShow();
						  }
					   })
					}, 2000) //延迟时间
				  }else{
					uni.showToast({
						title: res.resMessage,
						icon: 'none'
					})					
				  }
				  this.loading=false		
				})				
			}
			
		}
	}
</script>

<style>
	@import "./index.css";
</style>